
<template>
  <div class="downloadApp">
    <div class="img-containter">
      <!-- <img
        v-if="isWeiXin"
        src="../../public/static/img/public/app_tip.png"
        alt
        srcset
      />
      <img
        v-else
        src="../../public/static/img/public/app_downbg.png"
        alt
        srcset
      /> -->
    </div>
  </div>
</template>

<script>

export default {
  name: "downloadApp",
  data() {
    return {
      globalSet: {
        downloadUrl: {
          android_url: "",
          ios_url: "",
        },
      },
      isWeiXin: true,
    };
  },
  created() {

    // 获取终端的相关信息
    var Terminal = {
      // 辨别移动终端类型
      platform: (function () {
        var u = navigator.userAgent,
          app = navigator.appVersion;
        console.log(u);
        return {
          // android终端或者uc浏览器
          android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1,
          // 是否为iPhone或者QQHD浏览器
          iPhone: u.indexOf("iPhone") > -1,
          // 是否iPad
          iPad: u.indexOf("iPad") > -1,
        };
      })(),
      /* 判断是否为微信环境 */
      isWeiXin:
        navigator.userAgent.toLowerCase().indexOf("micromessenger") > -1
          ? true
          : false,
      // 辨别移动终端的语言：zh-cn、en-us、ko-kr、ja-jp...
      language: (navigator.browserLanguage || navigator.language).toLowerCase(),
    };
    this.isWeiXin = Terminal.platform.isWeiXin;

    // 测试下载
    // var theUrl = 'http://fir.im.snpit.cn/jfwd';
    var theUrl = this.globalSet.downloadUrl.android_url;
    if (Terminal.platform.android) {
      //安卓端
      theUrl = this.globalSet.downloadUrl.android_url;
      location.href = theUrl;
    } else {
      if (Terminal.platform.iPhone) {
        //iPhone端
        theUrl = this.globalSet.downloadUrl.ios_url;
        location.href = theUrl;
      } else if (Terminal.platform.iPad) {
        //iPad端
        // 还可以通过language，区分开多国语言版
        // switch (Terminal.language) {
        //   case 'en-us'://iPad英文版APP Store地址
        //     theUrl = 'https://itunes.apple.com/app/id1299542018';
        //     break;
        //   case 'ko-kr'://iPad韩语版APP Store地址
        //     theUrl = 'https://itunes.apple.com/app/id1299542018';
        //     break;
        //   case 'ja-jp'://iPad日文版APP Store地址
        //     theUrl = 'https://itunes.apple.com/app/id1299542018';
        //     break;
        //   default://iPad默认APP Store地址
        //     theUrl = 'https://itunes.apple.com/app/id1299542018';
        // }
      }

      location.href = theUrl;
    }
  },
};
</script>

<style scoped>
.downloadApp {
  width: 100%;
  height: 100%;
}
.img-containter {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.img-containter img {
  width: 100%;
}
</style>